package task4;

import java.util.Scanner;

public class Task3 {
    static Scanner input=new Scanner(System.in);
    public static void main(String[] args) {
        String str=input.nextLine();
        System.out.println(search(str));
    }

    private static int search(String str) {
        int len=1;
        int max=0;

        while (len<=str.length()/2)
        {
            for(int i=0;i<str.length()-len;i++)
            {
               String dest= str.substring(i,i+len);
               String rest= str.substring(i+1);
               if(rest.length()<dest.length())//截取的子串大于剩余待匹配的子串
                   break;

               if(rest.contains(dest))
                   if(dest.length()>max)
                   {
                       max=dest.length();
                       break;//当在长度为len的子串内找到的重复时，退出循环，因为再往后找就算有相同的也只会长度为len
                   }

            }
            len++;
        }

        return max;
    }

}
